Những câu hỏi liên quan
hùng tín trang
Xem chi tiết
Nguyễn Lê Phước Thịnh
14 tháng 3 2022 lúc 9:47

Bài 3: 

#include <bits/stdc++.h>

using namespace std;

long long x,n,i;

int main()

{

cin>>n;

for (i=0; i<=n; i++)

{

x=int(sqrt(i));

if (x*x==i) cout<<i<<" ";

}

return 0;

return 0;

}

Bình luận (0)
Tali
Xem chi tiết
Nguyễn Lê Phước Thịnh
12 tháng 4 2021 lúc 23:03

uses crt;

var a:array[1..100]of integer;

i,n,dem:integer;

begin

clrscr;

write('Nhap n='); readln(n);

for i:=1 to n do

begin

write('A[',i,']='); readln(a[i]);

end;

dem:=0;

for i:=1 to n do 

  if (10<a[i]) and (a[i]<20) then inc(dem);

writeln(dem);

readln;

end.

Bình luận (2)
Gà Công Nghệ
Xem chi tiết
Anh Phạm
28 tháng 8 2021 lúc 19:43

uses crt;

var n,i,o,d:integer;

function ktnt(n:integer): integer;

var i,d:integer;

begin

d:=0;

for i:=1 to sqrt(n) do

if (n mod i=0) then d:=d+1;

if d=2 then ktnt=0

else ktnt=1;

end;

begin

readln(n);

writeln(' so nguyen to be hon hoac bang n la'); {a}

for i:=1 to n do

if ktnt(i)=0 then writeln(i);

writeln('so nguyen to nho nhat khong be hon n');

o:=n;

while o>0 do

begin

if ktnt(o)=0 then

begin

write(o);

break;

end;

o:=o+1;

end;

writeln('cặp số nguyên tố là hai số nguyên lẻ liên tiếp nhỏ hơn hoặc bằng n');

o:=0;

o:=1;

d:=0;

for i:=o+2 to n do

begin

if ktnt(i)=0 then

begin

d:=d+1;

write(i,' ');

if d<2 then continue;

end;

d:=0;

writeln;

end;

readln;

end.

Bình luận (1)
Đoàn Phạm Phương Vy
Xem chi tiết
Long ca ca
Xem chi tiết
lynguyenmnhthong
13 tháng 6 2023 lúc 14:04

program abcdef;

uses Crt;

var

k, lowerLimit, upperLimit, i, j, reversed, temp, remainder: integer;

isPrime, isPalindrome: boolean; 

begin

clrscr;

write('Nhap so chu so k (1<=k<=9): ');

readln(k);

 lowerLimit := 1;

for i := 1 to k - 1 do

lowerLimit := lowerLimit * 10; 

upperLimit := lowerLimit * 10 - 1; 

writeln('Cac so nguyen to doi xung co ', k, ' chu so la:');

for i := lowerLimit to upperLimit do

begin

// Kiểm tra số nguyên tố

isPrime := True;

if i < 2 then

isPrime := False

else

for j := 2 to trunc(sqrt(i)) do

if i mod j = 0 then

beginisPrime := False;break;end;

// Kiểm tra số đối xứng

if isPrime then

begin

reversed := 0;

temp := i;

while temp <> 0 dobeginremainder := temp mod 10;

reversed := reversed * 10 + remainder;

temp := temp div 10;

end;

isPalindrome := (i = reversed);

 if isPalindrome then

writeln(i);

end;

end; 

readln;

end.

Bình luận (0)
Huyền Diệu Nguyễn
Xem chi tiết
Nguyễn Lê Phước Thịnh
24 tháng 12 2021 lúc 0:49

#include <bits/stdc++.h>

using namespace std;

long long n,i,a[1000];

int main()

{

cin>>n;

for (i=1; i<=n; i++) cin>>a[i];

sort(a+1,a+n+1);

for (i=n; i>=1; i--) cout<<a[i]<<" ";

return 0;

}

Bình luận (0)
Phan Thị Phương Thy
Xem chi tiết
Nguyễn Lê Phước Thịnh
28 tháng 4 2021 lúc 19:03

uses crt;

var a:array[1..100]of integer;

i,n,max,min:integer;

begin

clrscr;

write('Nhap n='); readln(n);

for i:=1 to n do 

  begin

write('A[',i,']='); readln(a[i]);

end;

max:=a[1];

min:=a[1];

for i:=1 to n do 

  begin

if max<a[i] then max:=a[i];

if min>a[i] then min:=a[i];

end;

writeln('So lon nhat la: ',max);

writeln('So nho nhat la: ',min);

readln;

end.

Bình luận (0)
Minh Lệ
28 tháng 4 2021 lúc 20:26

Program HOC24;

var a: array[1..32000] of integer;

i,max,min,n: integer;

begin

write('Nhap so phan tu N: '); readln(N);

for i:=1 to n do

begin

write('a[',i,']='); readln(a[i]);

end;

max:=a[1]; min:=a[1];

for i:=1 to n do

begin

if a[i]>max then max:=a[i];

if a[i]<min then min:=a[i];

end;

writeln('So nho nhat la :',max);

write('So lon nhat la: ',min);

readln

end.

Bình luận (0)
Nguyễn Trần Hồng Ngọc
Xem chi tiết
Phía sau một cô gái
7 tháng 5 2023 lúc 20:02

program TinhTBCTimSoNT;

var
  ten, lop: string;
  n, i, tong, dem: integer;
  A: array [1..11] of integer;
  trung_binh: real;

function LaSoNguyenTo(x: integer): boolean;
var
  i: integer;
begin
  if x < 2 then
    LaSoNguyenTo := false
  else if x = 2 then
    LaSoNguyenTo := true
  else if x mod 2 = 0 then
    LaSoNguyenTo := false
  else
  begin
    i := 3;
    while (i <= trunc(sqrt(x))) and (x mod i <> 0) do
      i := i + 2;
    LaSoNguyenTo := x mod i <> 0;
  end;
end;

begin
  // Nhập tên và lớp của học sinh
  write('Nhập tên của học sinh: ');
  readln(ten);
  write('Nhập lớp: ');
  readln(lop);

  // Nhập dãy số nguyên và tính trung bình cộng
  repeat
    write('Nhập số phần tử của dãy số (n<12): ');
    readln(n);
  until n < 12;
  tong := 0;
  for i := 1 to n do
  begin
    write('Nhập phần tử thứ ', i, ': ');
    readln(A[i]);
    tong := tong + A[i];
  end;
  trung_binh := tong / n;

  // In tên, lớp, dãy số và trung bình cộng ra màn hình
  writeln('Học sinh: ', ten);
  writeln('Lớp: ', lop);
  write('Dãy số: ');
  for i := 1 to n do
    write(A[i], ' ');
  writeln;
 
  // In các số nguyên tố của dãy số ra màn hình
  writeln('Các số nguyên tố của dãy số:');
  for i := 1 to n do
    if LaSoNguyenTo(A[i]) then
      writeln(A[i]);
end.

Bình luận (0)